package com.iseastar.guojiang.wallet;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.iseastar.guojiang.model.WalletTakeMoneyHistoryBean;
import com.shouhuobao.station.R;
import com.shouhuobao.take.weight.CircularImage;

import java.util.ArrayList;

import droid.frame.activity.base.BaseAdapterExt;
import droid.frame.utils.sqlite.DateUtils;

/**
 * 提现记录适配器
 * Created by lidandan on 2018/1/25.
 */
public class WalletTakeMoneyHistoryAdapter extends BaseAdapterExt<WalletTakeMoneyHistoryBean> {

    public WalletTakeMoneyHistoryAdapter(ArrayList<WalletTakeMoneyHistoryBean> items, Activity context) {
        super(items, context);
        setEmptyView(R.layout.wallet_take_money_history_empty);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (hasEmptyView()) {
            return super.getView(position, convertView, parent);
        }
        ViewHolder holder;
        if (convertView == null || convertView.getTag() == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.wallet_takem_oney_history_item, parent, false);
            holder = new ViewHolder();
            holder.maneyTV = (TextView) convertView.findViewById(R.id.maney_tv);
            holder.timeTV = (TextView) convertView.findViewById(R.id.time_tv);
            holder.statusTV = (TextView) convertView.findViewById(R.id.status_tv);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        WalletTakeMoneyHistoryBean item = items.get(position);
        holder.timeTV.setText(DateUtils.format(item.getCreateTime()));
        //1.待审核，11.审核通过，21.驳回
        if (item.getStatus() == 1) {
            holder.statusTV.setText("审核中");
            holder.maneyTV.setText(item.getMoney() + "元    金额冻结中");
        } else if (item.getStatus() == 11) {
            holder.statusTV.setText("已完成");
            holder.maneyTV.setText(item.getMoney() + "元");
        } else if (item.getStatus() == 21) {
            holder.statusTV.setText("审核失败");
            holder.maneyTV.setText(item.getMoney() + "元    已解冻");
        }

        return convertView;
    }

    class ViewHolder {
        private TextView maneyTV;
        private TextView timeTV;
        private TextView statusTV;

    }
}
